package logicGame.States;

import java.io.Serializable;
import logicGame.Board;
import logicGame.Cards.*;
import logicGame.Game;
import logicGame.Player;

public class PickPlace extends StateAdapter implements Serializable {

    public PickPlace(Game g) {
        super(g);
    }

    @Override
    public State choice(Player p, Board b, int i) {

        Card card = p.getLastCard();

        if (card.getAction() instanceof Delete && card.getNumAction() > 0) {
            getGame().setPlace(i);
            return new PickArmy(getGame());

        } else {
            if (card.getNumAction() > 0) {
                card.DoAction(p, b, getGame().getPlace(), i);
                getGame().setPlace(-1);
            }
        }

        if (card.getNumAction() > 0) {
            return this;

        } else if (card instanceof AndCard) {
            if (card.getTimes() < 2) {
                return new And(getGame());
            }
        }

        return proxPlayer();

    }
}
